<?php
if(@$_POST['open'] != 'please'){
	exit;
}
include_once("../../php/include_all.php");
session_start();
?>
<div class="row-fluid">
	<div class="span12">
		<div class="widget">
			<div class="widget-title" style="margin-top: 20px;">
                <h4><i class="icon-reorder"></i>Laporan Proyeksi dan Anggaran SPM</h4>
                <span class="tools">
                    <a href="javascript:;" class="icon-chevron-down"></a>
                </span>
            </div>
			<div class="widget-body form">
				<form id="form-bidang" method="POST" action="" class="form-horizontal">
					<input type="hidden" name="act" value="cari">
					<input type="hidden" id="id_bidang" name="id_bidang" value="0">
					<div class="control-group">
                        <label class="control-label">Bidang</label>
                        <div class="controls">
                            <select name="id_bidangcb" id="id_bidangcb">
								<option id="awal">Pilih salah satu</option>
								<?php
									$bidang = get_datas("select distinct b.id_bidang,b.nama_bidang from spm_skpd s,spm_bidang_urusan b, spm_jenis_pelayanan j,spm_indikator i where i.id_pelayanan=j.id_pelayanan AND b.id_bidang=j.id_bidang AND i.id_skpd=".$_SESSION['_id']."");
									foreach($bidang as $bidang){
								?>
									<option value="<?php echo $bidang['id_bidang'] ?>"><?php echo $bidang['nama_bidang'] ?></option>
								<?php
								}
								?>
							</select>
                        </div>
					</div>
					<div class="control-group">
                        <label class="control-label">Tahun Anggaran</label>
                        <div class="controls">
                            <select name="id_tahun" id="id_tahun">
								<option id="awal">Pilih salah satu</option>
								<?php
									$tahun = get_datas("SELECT DISTINCT t.thn_angg, t.id_thn_angg from spm_proyeksi pr,spm_jenis_pelayanan j,spm_thn_angg t,spm_indikator i where t.id_thn_angg=j.id_thn_angg AND pr.id_indikator=i.id_indikator AND i.id_pelayanan=j.id_pelayanan AND i.id_skpd=".$_SESSION['_id']." order by t.id_thn_angg asc");
									foreach($tahun as $thn){
								?>
									<option value="<?php echo $thn['id_thn_angg'] ?>"><?php echo $thn['thn_angg'] ?></option>
								<?php
								}
								?>
							</select>
                        </div>
					</div>
					<span id='alerti' style='margin-left: 13px;padding-bottom:3px;'></span>
					<div class="form-actions">
                        <button type="button" class="btn btn-primary btn-cari" onclick="laporan()">Cari</button>
                        <span id="result"></span>
                    </div>
				</form>
			</div>
		</div>
	</div>
	<div class="row-fluid">
        <div class="span12">
			<div class="widget" style="">
				<div class="widget-body">
					
                    <table class="table table-striped table-bordered" id="sample_1">
        <thead>
        <tr>
			<th rowspan="3" class="hidden-phone" style="width:50px; text-align:center;">Kode</th>
			<th rowspan="3" colspan="2"style="text-align:center; 	">Program, Indikator dan Kegiatan</th>
			<th rowspan="3" style="text-align:center;">Data Capaian Pada Perencanaan Awal</th>
			<th colspan="10"style="text-align:center;">Target Kinerja Program dan Kerangka Pendanaan</th>
			<th rowspan="3" style="text-align:center;">Unit kerja SKPD Penanggung jawab</th>
        </tr>
		<tr>
			<th colspan="2" style="text-align:center;"><?php echo 1 ?></th>
			<th colspan="2" style="text-align:center;"><?php echo 2 ?></th>
			<th colspan="2" style="text-align:center;"><?php echo 3 ?></th>
			<th colspan="2" style="text-align:center;"><?php echo 4 ?></th>
			<th colspan="2" style="text-align:center;"><?php echo 5 ?></th>
		</tr>
		<tr>
			<th style="text-align:center; width:80px;">Target</th>
			<th style="text-align:center; width:80px;">Rp</th>
			<th style="text-align:center; width:80px;">Target</th>
			<th style="text-align:center; width:80px;">Rp</th>
			<th style="text-align:center; width:80px;">Target</th>
			<th style="text-align:center; width:80px;">Rp</th>
			<th style="text-align:center; width:80px;">Target</th>
			<th style="text-align:center; width:80px;">Rp</th>
			<th style="text-align:center; width:80px;">Target</th>
			<th style="text-align:center; width:80px;">Rp</th>
		</tr>
    </thead>
                    <tbody id="tbody-laporan">
					
					</tbody>
					</table>
					<div style="margin:10px;" class="pull-right">
						<a style="margin:10px;" class="btn btn-primary" href="" id='printxls' target="_blank"><i class="icon-print"></i>&nbsp;Cetak Excel</a>
						<a class="btn btn-primary" href="" id='printpdf' target="_blank"><i class="icon-print"></i>&nbsp;Cetak PDF</a>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
    jQuery(document).ready(function() {       
         // initiate layout and plugins
        App.init();
    });
	
</script>	
<script>
var url = 'master_laporan_akhir/laporan_action.php';
function laporan(){
	var btn = $(this);
	var bidang = $('#id_bidangcb').val();
	var tahun = $('#id_tahun').val();
	
	var post = $.post(url, {act: 'tmpl_laporan', b:bidang, t:tahun});
	post.done(function(ok){
		var isi = ok.split('__');
		if(isi.length == 2){
			if(isi[0] == 'ok'){
				$('#tbody-laporan').html(isi[1]);
				$('#printpdf').attr('href','master_laporan_akhir/printPHP.php?b='+bidang+'&t='+tahun);
				$('#printxls').attr('href','master_laporan_akhir/printXLS.php?b='+bidang+'&t='+tahun);
			}else if(isi[0] == 'err'){
				$('#alerti').removeClass().addClass('alert alert-error');
				$('#alerti').html('Error !!!' + isi[1]);
				setTimeout(function(){
					$('alerti').removeClass();
				}, 1500);
			}
		} else{
			$('#alerti').removeClass().addClass('alert alert error');
			$('#alerti').html('Gagal Mengambil data ');
			setTimeout(function () {
				$('#alerti').removeClass();
				$('#alerti').html('');
			}, 1500);
		}
	});
}
</script>